export function len(val: string) {
    if(typeof val !== 'string') {
        return -1;
    }
    let length = 0;
    for(let i = 0; i < val.length; i++) {
        if(val.charCodeAt(i) > 127 || val.charCodeAt(i) === 94) {
            length += 2;
        } else {
            length += 1;
        }
    }
    return length;
}